package com.uzai.console.web.uzaichat;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.uzaichat.baseconfig.UzaichatBaseConfigDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.mapper.MerBaseConfigMapper;
import com.uzai.console.mapper.SysDomainMapper;
import com.uzai.console.service.configplan.ConfigPlanService;
import com.uzai.console.service.uzaichat.UzaichatBaseConfigService;
import com.uzai.console.vo.uzaichat.baseconfig.UzaichatBaseConfigVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * CMS小程序|基础设置
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "基础设置",tags = "客服管理|悠聊设置")
@ApiSort(20)
@RestController
public class UzaichatBaseConfigController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(UzaichatBaseConfigController.class);

    @Autowired
    private UzaichatBaseConfigService uzaichatBaseConfigService;
    @Autowired
    private SysDomainMapper sysDomainMapper;
    @Autowired
    private MerBaseConfigMapper merBaseConfigMapper;
    @Autowired
    private ConfigPlanService configPlanService;


    @ApiOperation(value = "查询悠聊基础设置", notes = "查询悠聊基础设置", response = UzaichatBaseConfigVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/uzaichatBaseConfig/findUzaichatBaseConfig")
    public Object findUzaichatBaseConfig(){
        return uzaichatBaseConfigService.findUzaichatBaseConfig(getLoginInfo().getMerId());
    }

    @SystemLogType(model = SystemModelEnum.UzaichatBaseConfig, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "保存悠聊基础设置信息", notes = "保存悠聊基础设置信息")
    @ApiOperationSupport(order = 2)
    @PostMapping("/uzaichatBaseConfig/updateUzaichatBaseConfig")
    public Object updateUzaichatBaseConfig(@RequestBody UzaichatBaseConfigDto uzaichatBaseConfigDto){
        uzaichatBaseConfigService.updateUzaichatBaseConfig(uzaichatBaseConfigDto);
        return true;
    }
}
